<template>
  <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
    <div class="Logout">
      <Logout>退出</Logout>

   <div class="image">
       <el-image :src="src2"></el-image>
       <!-- <el-image :src="src1"></el-image> -->
    </div>
     



    </div>
<!--    <el-button type="danger" @click="Logout">退出登录</el-button>-->
    <h1>添加事件信息</h1>
    
   
   
    
     <el-form-item label="事件编号" prop="eid">
      <el-input style="width: 800px" v-model="ruleForm.eid" placeholder="请输入事件编号" prefix-icon="el-icon-s-check" maxlength="10" show-word-limit clearable></el-input>
    </el-form-item>
   
    <el-form-item label="人员ID" prop="ename">
      <el-input style="width: 800px" v-model="ruleForm.ename" placeholder="请输入人员ID" prefix-icon="el-icon-user-solid" maxlength="50" show-word-limit clearable></el-input>
    </el-form-item> 
   

    <el-form-item label="事件时间" prop="ebirth">
    <el-input style="width: 800px" v-model="ruleForm.ebirth" placeholder="请输入事件时间" prefix-icon="el-icon-s-management" maxlength="50" show-word-limit clearable></el-input>
    </el-form-item>
   
   

     <!-- <el-form-item label="家训" prop="edie">
      <el-input style="width: 800px" v-model="ruleForm.edie" placeholder="请输入家训" prefix-icon="el-icon-s-management" maxlength="50" show-word-limit clearable></el-input>
    </el-form-item> -->


 <el-form-item label="事件类型" prop="emarry">
      <el-input style="width: 800px" v-model="ruleForm.emarry" placeholder="请输入事件类型" prefix-icon="el-icon-s-management" maxlength="50" show-word-limit clearable></el-input>
    </el-form-item>

 
    


<el-form-item label="事件描述" prop="epartner">
      <el-input style="width: 800px" v-model="ruleForm.epartner" placeholder="请输入事件描述" prefix-icon="el-icon-s-management" maxlength="50" show-word-limit clearable></el-input>
    </el-form-item>




<el-form-item label="事件附件" prop="echild">
      <el-input style="width: 800px" v-model="ruleForm.echild" placeholder="请输入事件附件" prefix-icon="el-icon-s-management" maxlength="50" show-word-limit clearable></el-input>
    </el-form-item>


<!-- <el-form-item label="恩荣录" prop="elife">
      <el-input style="width: 800px" v-model="ruleForm.elife" placeholder="请输入生平事迹" prefix-icon="el-icon-s-management" maxlength="50" show-word-limit clearable></el-input>
    </el-form-item>

<el-form-item label="联系方式" prop="eaddress">
      <el-input style="width: 800px" v-model="ruleForm.eaddress" placeholder="请输入族长联系方式" prefix-icon="el-icon-s-management" maxlength="50" show-word-limit clearable></el-input>
    </el-form-item>


<el-form-item label="更新时间" prop="ehonor">
      <el-input style="width: 800px" v-model="ruleForm.ehonor" placeholder="请输入生前荣誉" prefix-icon="el-icon-s-management" maxlength="50" show-word-limit clearable></el-input>
    </el-form-item> -->


    <el-form-item>
      <el-button type="success" @click="submitForm('ruleForm')" icon="el-icon-check">提交</el-button>
      <el-button type="danger" @click="resetForm('ruleForm')" icon="el-icon-refresh">重置</el-button>
    </el-form-item>
  </el-form>
  
 





</template>

<script>
import Logout from "./Logout";
export default {
  name: "AddEvent",
  components: {Logout},
  data () {
    return {

       src2:"https://pic1.zhimg.com/v2-a1c23155b0ee6f7f8d10379282371105_1440w.jpg?source=172ae18b",
      ruleForm: {
        eid: '',
        ename: '',
    //    elevel: '',
    //    etype: '',
        eaddress: '',
        edie:'',
        emarry:'',
        epartner:'',
        elife:'',
        ebirth:'',
        echild:'',
        ehonor:'',
      },
      rules: {
        eid:
          {required: true, message: '请输入成员编号', trigger: 'blur'},

        ename:
          {required: true, message: '请输入成员姓名', trigger: 'blur'},

    //      elevel:
    //      {required: true, message: '请输入等级', trigger: 'change'},

    //    etype:
    //     {required: true, message: '请输入特长', trigger: 'blur'},

        eaddress:
          {required: true, message: '请输入家庭地址', trigger: 'blur'},

          edie:
          {required: true, message: '请输入死亡时间', trigger: 'blur'},

          emarry:
          {required: true, message: '请输入结婚日期', trigger: 'blur'},

          epartner:
          {required: true, message: '请输入配偶信息', trigger: 'blur'},

          elife:
          {required: true, message: '请输入生平事迹', trigger: 'blur'},

          
          ebirth:
          {required: true, message: '请输入出生日期', trigger: 'blur'},

          echild:
          {required: true, message: '请输入子女信息', trigger: 'blur'},

          ehonor:
          {required: true, message: '请输入生前荣誉', trigger: 'blur'},

      },
    }
  },
  methods : {
    submitForm(formName) {
      const _this=this
      this.$refs[formName].validate((valid) => {
        if (valid) {
          console.log(_this.ruleForm)
          //这个地方进行axios提交后台信息
          const params = {
            eno:_this.ruleForm.eid,
            ename:_this.ruleForm.ename,
       //     elevel:_this.ruleForm.elevel,
       //     echaracter:_this.ruleForm.etype,
            eaddress: _this.ruleForm.eaddress,
            edie:_this.ruleForm.edie,
            emarry:_this.ruleForm.emarry,
            epartner:_this.ruleForm.epartner,
            elife:_this.ruleForm.elife,
            ebirth:_this.ruleForm.ebirth,
            echild:_this.ruleForm.echild,
            ehonor:_this.ruleForm.ehonor

          }
          console.log("eno:", params.eno, " ename:", params.ename, " elevel:", params.elever, " ec:", params.echaracter)
          this.$axios.post(`/InsertEvent`,params).then((res) => {   // 请求后端  给后端传参数  在执行then（res）之前，先向后端请求，前端一直等待后端返回的状态码
            console.log(res);   
            
      //       if (res.data.msg=="插入家族成员成功") { //如果返回信息，则插入成功
      //         alert("插入家族成员成功")
      //       } else {
      //         alert(res.data.msg)
      //       }
      //     });
      //     //alert('提交成功!');
      //   }
      // });
     if (res.data.msg=="插入事件成功") { //如果返回信息，则插入成功
              alert("插入事件成功")
            } else {
              alert("插入事件失败")
            }
          });
          //alert('提交成功!');
        }
      });
   
   
   
   },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
    Logout() {
      var _this = this;
      _this.$confirm('确认退出吗？', '提示', {}).then(() => {
        window.location.href = '/'
      }).catch(() => {})
    },
  }
}
</script>

<style scoped>

</style>
